package com.byxy.service.impl;

import com.byxy.dao.AdminGroupDao;
import com.byxy.dao.AdminRuleDao;
import com.byxy.model.AdminGroup;
import com.byxy.model.AdminRule;
import com.byxy.service.AdminGroupTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class AdminGroupTagServiceImpl implements AdminGroupTagService {
    @Autowired
    private AdminGroupDao adminGroupDao;
    @Autowired
    private AdminRuleDao adminRuleDao;

    @Override
    public Map<Integer, String> listPid() {
        List<AdminGroup> list = adminGroupDao.listPage(0, 0, "");
        Map<Integer, String> map = new HashMap<>();
        map.put(null, "无");
        for (AdminGroup e : list) {
            map.put(e.getId(), e.getTitle());
        }
        return map;
    }

    @Override
    public Map<Integer, String> listRule() {
        List<AdminRule> adminRuleList = adminRuleDao.listPage(0, 0, "");
        Map<Integer, String> map = new HashMap<>();
        for (AdminRule e : adminRuleList) {
            map.put(e.getId(), e.getTitle());
        }
        return map;
    }
}
